import { defineStore } from 'pinia'
import { deepIndex } from '@/utils'

export const useRouteStore = defineStore('routeStore', {
  state() {
    return {
      routes: [] as any[],
      navbar: [] as any[],
    }
  },

  actions: {
    updateRoutes(results: any[]) {
      this.routes = results
    },
    updateNavbar(results: any[]) {
      this.navbar = deepIndex(results).map((item) => {
        return {
          ...item,
          disabled: false,
        }
      })
    },
  },
})
